package top.kaoshanji.p1ch06b;

/**
 * 代码清单-p1ch06b-126页b：静态子句里的显式静态初始化
 * author kaoshanji
 * ^_^
 * create time 2025/3/8 18:08
 */
public class ExplicitStatic {

    public static void main(String[] args) {
        System.out.println("Inside main()");
        Cups.cup1.f(99);

    }


}

class Cup {
    Cup(int marker) {
        System.out.println("Cup(" + marker + ")");
    }
    void f(int marker) {
        System.out.println("f(" + marker + ")");
    }
}

class Cups {
    static Cup cup1;
    static Cup cup2;

    // 在类被加载时就会被执行
    static {
        cup1 = new Cup(1);
        cup2 = new Cup(2);
    }

    // 没有对象的事情
    Cups() {
        System.out.println("Cups()");
    }

}